<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>实例1</title>
<script type="text/javascript">
window.onload = function(){
	//1.获取a结点，并为其添加onclick响应函数
	document.getElementsByTagName('a')[0].onclick = function(){
		//3。创建一个XMLHttpRequest对象
		var request = new XMLHttpRequest();
		//4.准备发送的请求数据：URL
		var url = this.href+"?time="+new Date();
		var method = "GET";
		//5.调用XMLHttpRequest对象的open方法
		request.open(method,url);
		//6.调用XMLHttpRequest对象的send方法
		request.send(null);
		//7.为XMLHttpRequest对象添加onreadystatechange响应函数
		request.onreadystatechange = function(){
			//8.判断响应是否完成：XMLHttpRequest对象的属性值为4的时候
			if(request.readyState == 4){
				//9。再判断响应是否可用：XMLHttpRequest对象的status属性值为200时
				if(request.status == 200||request.status == 304){
					//10.打印响应结果responseText
					alert(request.responseText);
				}
			}
		}
		
		//2.取消其默认行为
		return false;
	}
}
</script>
</head>
    <body>
    <a href="helloAjax.txt">hello ajax!</a>
    </body>
</html>